import React from 'react';
import { Route } from 'react-router-dom';
import { getToken } from 'utils/storage';

export default function AuthRouter(props) {
  const { path, component: Component } = props;
  return <Route path={path} render={
    _props => {
      // return getToken() ? <Component {..._props}></Component> : _props.history.push("/login");
      if(getToken()){
        return  <Component {..._props}></Component> 
      }else{
        _props.history.push("/login")
      }
    }
  }></Route>;
}
